import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

const state = {
    userName:'',
    cartNum:0,
};
const mutations = {
    setUserName(state,payload){
        state.userName = payload
    },
    setCartNum(state,payload){
        state.cartNum = payload
    },
    addCartNum(state,payload){
        state.cartNum += payload
    },
    subCartNum(state,payload){
        state.cartNum -= payload
    }
}
const store = new Vuex.Store({
    state:state,
    mutations:mutations,
});

export default store;